using System;
using System.Globalization;
using System.Windows.Data;

namespace PCR.Converter
{
	public class TwoDoubleAverageConverter : IMultiValueConverter
	{
		public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
		{
			double result = 0.0;
			double result2 = 0.0;
			double.TryParse(values[0].ToString(), out result);
			double.TryParse(values[1].ToString(), out result2);
			if (targetType.Name == "String")
			{
				return string.Format("{0}℃", result2 - result);
			}
			return (result + result2) / 2.0;
		}

		public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
		{
			return null;
		}
	}
}
